1. Field of the Invention
This invention relates to a method and an apparatus for encoding which uses variable-length codes.
2. Description of the Prior Art
Some video signal transmission systems include a combination of a quantizer and an encoder for converting a video signal into variable-length codes. Such encoding enables a reduction of an amount of transmitted information data and thus an efficient transmission of the data.
In typical encoding which uses variable-length codes, Huffman codes are generated in accordance with the frequencies of occurrence of respective data values which are previously determined statistically. In this case, the amount of the coded data is close to the amount of original information.
In some encoding, pixel data values are subjected to an orthogonal transform such as a discrete cosine transform, and generated transform coefficients are quantized. Generally, most of the quantized transform coefficients are "0". The average information amount per pixel is sometimes smaller than a level corresponding to one bit. In cases where codes are allotted to the respective transform coefficient values, since a code having at least one bit is necessary for "0", the average code length tends to be large with respect to the amount of the original information so that the transmission efficiency tends to be low.
Accordingly, in improved encoding, a variable-length code is not allotted to each of the zero transform coefficients but a group of the zero transform coefficients is encoded together. To discriminate the code for a group of the zero transform coefficients from codes for non-zero transform coefficients, the absence of "0" is encoded in the case where non-zero transform coefficients appear in succession.
Specifically, run length codes (zero run codes) are used to represent the number of successively-appearing zero transform coefficients. In cases where a frame of a video signal is divided into two-dimensional blocks and an orthogonal transform is applied to each of these signal blocks, the two-dimensional signal sequence is rearranged into a one-dimensional signal sequence by a suitable way such as a zigzag scanning process.
In view of the fact that the zero run codes and the codes for the non-zero transform coefficients appear alternately, some encoding systems pair these codes and thereby generate two-dimensional variable-length codes. Generally, a last zero run set, which is not followed by a code for a non-zero transform coefficient, is not encoded in length but is expressed in common by the code representing the absence of a non-zero transform coefficient. This code is referred to as an EOB (end of block) code.
In encoding which uses an orthogonal transform, as the size of signal blocks increases, the encoding efficiency rises but quantization errors spread over a wider region. On the other hand, as the size of blocks decreases, the encoding efficiency drops and also the following problems arise. For example, in cases where successive blocks have differential-type transform coefficients which are all "0", an EOB code is necessary for each of the blocks and a larger number of EOB codes are necessary for one frame. Furthermore, the run lengths are short and the number of different types of the codes is small, so that the average code length tends to be large in the case of Huffman codes.